<?php
/**
* Copyright 2009 Waag Society <http://www.waag.org>
* This file is part of Annotrax.
*
* Annotrax is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* Annotrax is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Annotrax.
* If not, see http://www.gnu.org/licenses/gpl.html
*/
class Default_Form_Login extends Zend_Form{
     //const ENDPOINT_0   = "OpenId.org:%username.openid.org";
	const ENDPOINT_0   = "Google account:www.google.com/accounts/o8/id";
	const ENDPOINT_1   = "Yahoo account:me.yahoo.com";
	const ENDPOINT_2   = 'Hyves account:hyves.nl';

    //const ENDPOINT_1   = "MyOpenId:%username.myopenid.com";
    //const ENDPOINT_2   = "ClaimID:claimid.com/%username";
    //const ENDPOINT_3   = "Verisign:%username.pip.verisignlabs.com";
    //const ENDPOINT_4   = "Hyves:%username.hyves.nl";
    //const ENDPOINT_5   = "Yahoo:me.yahoo.com/%username";
    //const ENDPOINT_6   = "Blogspot:%username.blogspot.com";
    //const ENDPOINT_7   = "Wordpress.com:%username.wordpress.com";
    //const ENDPOINT_8   = "Technorati:technorati.com/people/technorati/%username";

	public function getEndPoints(){
		$endpoints = array(
			self::ENDPOINT_0,
			self::ENDPOINT_1,
			self::ENDPOINT_2,
			//self::ENDPOINT_3,
			//self::ENDPOINT_4,
			//self::ENDPOINT_5,
			//self::ENDPOINT_6,
			//self::ENDPOINT_7,
			//self::ENDPOINT_8
		);

		foreach( $endpoints as $value ){
			list( $value, $key ) = explode( ':', $value );
			$collect[$key]	= $value;
		}

		return $collect;
	}

    public function init(){
        $this->setMethod('post');
        $this->setAction( '/user/login' );

        $element = new Zend_Form_Element_Select( 'endpoint' );

		foreach( $this->getEndpoints() as $key => $value ){
            $element->addMultiOption($key, $value);
		}

        //$element->addMultiOption( 0, 'Custom' );
        //$element->setValue( array(0) );
        //$element->setRequired( true );


        $this->addElement( $element );

		$this->addElement('text', 'endpoint_custom', array(
			'validators' => array('Zend_Validate_Hostname'),
			'description'	=> "Alternatively, you may enter a custom OpenID endpoint here"
		));

        $element = new Zend_Form_Element_Submit('submit');
        $element->setIgnore( true );

        $this->addElement( $element );
    }
}
